package com.yanzhengwu.boot.core.common.util;

import java.security.InvalidParameterException;
import java.util.InvalidPropertiesFormatException;
import java.util.Objects;

/**
 * 描述:
 *
 * @author yanzhengwu
 * @create 2022-11-25 20:58
 */
public class DynamicAssert {


    public static void passwordCallbackCheck(String classPath) throws InvalidPropertiesFormatException {
        try {
            ClassLoader.getSystemClassLoader().loadClass(classPath);
        } catch (ClassNotFoundException e) {
            //e.printStackTrace();
            throw new InvalidPropertiesFormatException("passwordCallback filed is required");
        }

    }

    public static void connectionPropertiesCheck(String connectionProperties) throws InvalidPropertiesFormatException {
        if (Objects.isNull(connectionProperties))
            return;
        if (!connectionProperties.endsWith(";"))
            throw new InvalidParameterException("connectionProperties filed ending ' ; ' is required");

    }
}
